#include<iostream>
#include<vector>
#include<queue>
#include<cstring>
#include<cmath>
#include<map>
#include<set>
#include<cstdio>
#include<algorithm>
#define debug(a) cout<<#a<<"="<<a<<endl;
using namespace std;
const int maxn=1e3+100;
typedef long long LL;
inline LL read(){LL x=0,f=1;char ch=getchar();	while (!isdigit(ch)){if (ch=='-') f=-1;ch=getchar();}while (isdigit(ch)){x=x*10+ch-48;ch=getchar();}
return x*f;}
map<LL,LL>map1,map2;
vector<LL>ans;
LL a[maxn];
int main(void){
   cin.tie(0);std::ios::sync_with_stdio(false);
   LL n;cin>>n;
   for(LL i=1;i<=n;i++) cin>>a[i],map1[a[i]]++;
   for(LL i=n;i>=1;i--){
      if(!map2.count(a[i])) map2[a[i]]++,ans.push_back(a[i]);
      for(auto j:map2){
         LL t=__gcd(a[i],j.first);
         if(!map1.count(t)){
            cout<<"-1"<<"\n";
            return 0;
         }
         else{
            map2[t]++;
         }
      }
   }
   ///reverse(ans.begin(),ans.end());
   cout<<ans.size()<<"\n";
   for(auto i:ans){
       cout<<i<<" ";
   }
   cout<<"\n";
   return 0;
}
